package 剑指offer_专项突破版;

public class Num012 {
    public int pivotIndex(int[] nums) {
        int total = 0;
        for(int num : nums){
            total += num;
        }
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
            if(sum - nums[i] == total - sum){
                return i;
            }
        }
        return -1;
    }
}
